<%# $Id: index.rhtml 175 2009-06-27 15:42:20Z toshiyuki.ando1971 $
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>
<style type="text/css">
<!-- div#content {
  background-image: url("<%="#{@settings.url}images/hudson.png"%>");
  background-position: left bottom;
  background-repeat: no-repeat;
} -->
</style>
<h2><%=l(:label_job_list)%></h2>

<% if @jobs.length == 0 %>
  <div class="nodata"><%=l(:notice_no_jobs)%></div>
<% else %>
  <div class="flash notice" id="info" style="display:none;">build accepted</div>
  <div class="flash error" id="error" style="display:none;">build failure</div>
  <div id="remote-debug" style="display:none;"></div>

  <% @jobs.each do |job|%>
    <div class="contextual">
    <%= link_to_remote_if_authorized '[Build Now]',
          :url => {:action => 'build', :id => @project, :name => job.name},
          :update => {:success => 'remote-debug', :failure => 'remote-debug'},
          :success => "if(request.responseText.indexOf('build_accepted') > 0 ){Element.show('info');Element.hide('error');}else{Element.show('error');Element.hide('info');}",
          :failure => "Element.show('error');Element.hide('info');"
    %>
    </div>

    <div class="contextual latest-build" id='latest-build-<%=job.name%>'>
      <%=job.latest_build.error if "" != job.latest_build.error%>
      <% if "" == job.latest_build.error %>
        <% if "" != job.latest_build.number %>
          <%=image_tag 'document.png', :class=>'icon-build-history', :id=>"build-history-#{job.name}"%>
          <%=link_to "##{job.latest_build.number}", job.latest_build.url%>
          <%=content_tag("span", job.latest_build.result, :class => "result #{job.latest_build.result.downcase}") if true != job.latest_build.building && "" != job.latest_build.result%>
          <%=content_tag("span", l(:notice_building), :class => "result") if true == job.latest_build.building %>
          <%=content_tag("span", job.latest_build.finished_at.localtime.strftime("%Y/%m/%d %H:%M:%S")) %>
        <% end %>
        <%=l(:notice_no_builds) if "" == job.latest_build.number%>
      <% end %>
    </div>

    <div class="job-state">
    <h3 class="icon icon-<%=job.state%>"><%=link_to job.name, job.url%></h3>
    <% if @settings[:show_compact] != true %>
      <div class="wiki">
        <%= textilizable job.description -%>
      </div>

      <ul>
        <% job.health_reports.each do |report| %>
          <%="<li>#{link_to(report.description, report.url)} #{report.score}%" if report.url != ""%>
          <%="<li>#{report.description} #{report.score}%" if report.url == ""%>
        <% end %>
      </ul>
    <% end %>
    </div>
  <% end %>

  <div id="build-history" style="display:none;"></div>
  <%= javascript_tag "new BuildHistory('#{url_for(:controller => 'hudson', :action => 'history', :id=>@project)}')" %>
<% end %>

<% content_for :sidebar do %>
  <%= render :partial => 'hudson_sidebar' %>
<% end %>

<style type="text/css"></style>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag "hudson.css", :plugin => "redmine_hudson", :media => "screen" %>
  <%= javascript_include_tag 'build_history', :plugin => "redmine_hudson" %>
<% end %>
